home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr22
/
savag387.zip
/
SAV387.ASM
next >
Wrap
Assembly Source File
|
1993-05-06
|
1KB
|
86 lines
PAGE 66,132
;
; SAV_387.ASM Ray Berry, 2/21/90
; CIS 73407,3152
; uucp ...ole!ray
;
; An assembly language 80387 implementation of the 'savage'
; floating point benchmark. This module will *not* execute
; properly on 8087/80287 chips.
;
; the code:
;
; double a = 1.0;
; for(i=0; i<2500; i++)
; a=tan(atan(exp(log(sqrt(a*a)))))+1.0;
;
.MODEL small, c
.DATA
scratch DW ?
result DQ ?
a DQ 1.0
PUBLIC result
.CODE
savage proc
; first init FPU and set rounding mode to 'floor'. This is
; used for the exponentiation code.
finit
fstcw scratch
fwait
or byte ptr scratch+1, 0C0H
fldcw scratch
mov cx, 25000 ; iteration counter
cld
fld qword ptr a ; 'a' is carried on FPU stack throughout
; turn crank
doloop:
fld st ; dup a
fmul ; a*a
fsqrt ; sqrt
fldln2 ; log base e
fxch
fyl2x
; exp - requires a bit of fooling around, since the 387 limits
; its exponentiation arguments to +/- 1.
fldl2e ; scale for base e
fmul
fld st ; copy arg
frndint ; drop frac part, result is scale factor
fsub st(1), st ; sub int(x) from x
fxch ; frac part on TOS
f2xm1 ; compute 2^x-1
fld1 ; add the 1
fadd
fscale ; scale according to orig argument
fstp st(1) ; pop the scale factor
; atan
fld1
fpatan ; arg is st1/st
; tan
fptan ; result is y/x = st1/st
fdiv
; plus 1.0
fld1
fadd
loop doloop
fstp result
ret
savage endp
END